import { http } from '@/utils/http'
import type { cardItem } from '@/types/cart'
// 加入购物车
export const addCardAPI = (skuid: string, count: number) => {
  return http({
    url: '/member/cart',
    method: 'POST',
    data: { skuid, count },
  })
}
// 获取购物车列表
export const getCardListAPI = () => {
  return http<cardItem[]>({
    url: '/member/cart',
    method: 'GET',
  })
}
// 删除/清空购物车单品
export const deleteCardAPI = (ids: String[]) => {
  return http({
    url: `/member/cart`,
    method: 'DELETE',
    data: { ids },
  })
}
// 修改购物车单品
export const updateCardAPI = (skuid: string, data: { count: number; selected: boolean }) => {
  return http({
    url: `/member/cart/${skuid}`,
    method: 'PUT',
    data,
  })
}
// 购物车全选/取消全选
export const selectAllAPI = (selected: boolean) => {
  return http({
    url: `/member/cart/selected`,
    method: 'PUT',
    data: { selected },
  })
}
